package com.yang.mapper;

import com.yang.entity.OrderDetails;
import com.yang.entity.OrderItem;
import com.yang.entity.OrderMaster;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper {

    /**
     * 根据用户id查询订单信息
     * @param userId 用户id
     * @return
     */
    @Select("select \n" +
            "\torder_item_id, order_master_id, address.*, commodity_name, user_purch_quantity, order_item_price, total_price, create_time \n" +
            "from \n" +
            "\taddress join order_item on order_item.address_id = address.address_id join commodity on order_item.commodity_id = commodity.commodity_id\n" +
            "WHERE\n" +
            "\torder_item.user_id = 3\n" +
            "order BY\n" +
            "\torder_master_id;\n")
    List<OrderDetails> getOrderListByUserId(Integer userId);

}
